//
//  NewWSSureOrderCell.m
//  FD
//
//  Created by xiaofang wang on 2018/11/21.
//  Copyright © 2018年 ZhiYuan Network. All rights reserved.
//  外送确认订单表头 cell 需要高度自适应

#import "NewWSSureOrderCell.h"
@interface NewWSSureOrderCell()
//@property (weak, nonatomic) IBOutlet UILabel *nameLb;

//label高度自适应,不要设置底部约束
@property (nonatomic, strong) UILabel *nameLb;
//灰色的线
@property (nonatomic, strong) UIView *lightGrayLineView;
@end

@implementation NewWSSureOrderCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.selectionStyle = UITableViewCellSelectionStyleNone;
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        [self.contentView addSubview:self.nameLb];
        [self.contentView addSubview:self.lightGrayLineView]; //线
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}


- (void)layoutSubviews {
    [super layoutSubviews];
    
    [self.nameLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(15);
        make.right.equalTo(self.contentView.mas_right).offset(-15);
        make.top.equalTo(self.contentView.mas_top).offset(5);
        
        //cell高度自适应 : 核心不要设置底部约束
//        make.bottom.equalTo(self.contentView.mas_bottom).offset(-5);
    }];
    
    [self.lightGrayLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.nameLb.mas_bottom).offset(5);
        make.left.equalTo(self.contentView.mas_left).offset(15);
        make.right.equalTo(self.contentView.mas_right).offset(-15);
        make.height.mas_equalTo(1);
    }];
}

//getter
- (UILabel *)nameLb {
    if (!_nameLb) {
        _nameLb = [[UILabel alloc] init];
        _nameLb.textColor = kLightGrayTextColor;//浅灰色
        _nameLb.numberOfLines = 0;
    }
    return _nameLb;
}

//线
- (UIView *)lightGrayLineView {
    if (!_lightGrayLineView) {
        _lightGrayLineView = [[UIView alloc] init];
        _lightGrayLineView.backgroundColor = [UIColor rb_colorHex:0xF6F6F6];
    }
    return _lightGrayLineView;
}


- (void)setModel:(NewCanPinMsgModel *)model {
    _model = model;
    self.nameLb.text = model.name;
}

@end
